package com.wn.cloud.seata.config;

import com.zaxxer.hikari.HikariDataSource;
import io.seata.rm.datasource.DataSourceProxy;
import org.springframework.boot.autoconfigure.jdbc.DataSourceProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Primary;

/**
 * @FileName: DataSourceConfig
 * @Description: TODO
 * @Author: MaWenHao
 * @Created: 2020/4/17 - 16:55
 * @Version: V1.0
 * @Company: 东方微银科技（北京）有限公司
 */
@Configuration
public class DataSourceProxyConfig {

    @Bean
    @Primary
    public DataSourceProxy dataSourceProxy(DataSourceProperties properties){
        HikariDataSource dataSource = properties.initializeDataSourceBuilder().type(HikariDataSource.class).build();
        return new DataSourceProxy(dataSource);
    }
}
